
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>public/skin/back-end/css/tablemain.css"/>
<?php $title_show = empty ($datacontent['id'])?"Add":"Edit"; ?>
<h1>Menu System <span class="greysubheading"><?php echo $title_show; ?></span></h1>
<form id="menu-form" action="" method="POST" enctype="multipart/form-data" name="form">
<table width="100%" cellspacing="1">
<thead>
<tr>
<th scope="col">Fields</th>
<th scope="col">Data's</th>
</tr>
</thead>
<tbody>
<?php echo textfield('title','Title',((array_key_exists('title', $datacontent))?$datacontent['title']:null))?>
<?php echo plaintext('description','Description',((array_key_exists('description', $datacontent))?$datacontent['description']:null))?>
<?php echo dropdown('language','Language',$langList, ((array_key_exists('language', $datacontent))?$datacontent['language']:null))?>          
</tbody>
<tfoot>
<tr>
<th scope="row"></th>
<td><!--pagination -->
<div id="central" align="center">
<table>
<tr>
<td><input type="submit" id="button" value="Edit" /></td>
<td><input type="reset" id="reset" value="Reset" onClick="location.reload(true)"/></td>
</tr>
</table>
</div></td>
</tr>
</tfoot>
</table>
<p>&nbsp;</p>
</form>
<script>
$(document).ready(function(){
	var menuOptions = {
	            dataType: 'json',
	            url: '<?php echo $_SERVER['REQUEST_URI'];?>',
	            type: 'post', 
	            beforeSubmit:  function(formData, jqForm, options) {
	            	$.prompt('Please wait...',{ buttons: {}});
	        	    return true;
	            },
	            success: function (responseText, statusText) {
	                jQuery.prompt.close();
	                if(responseText.success == true){
	                	$.prompt('Update successfully.',{
	               		 submit:function(v,m){
	               			 if(v == true){
	               				 location.href = "<?php echo base_url()?>admin/menu_item/index/"+responseText.id;
	               			 }
	               			 return true;
	               		 },
	               		 buttons: { Ok:true}
	               		 });			    				
	        		}
	    			else $.prompt('Can not save!',{ buttons: { Ok: true }});
		        	return false;
	            },
	            error: function (responseText, statusText){
	                jQuery.prompt.close();
	            	$.prompt('Can not save!',{ buttons: { Ok: true }});
	            	return false;
	            }
	     };	
		$('#menu-form').submit(function() {
			$("#menu-form").ajaxSubmit(menuOptions); 
			  return false;
			});
});
</script>				